home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / pcr / pcr4_4.lha / DIST / debugnub / CirioNubProcs2.c < prev    next >
C/C++ Source or Header  |  1992-04-16  |  3KB  |  149 lines

  1. /* begincopyright
  2.   Copyright (c) 1988-1989 Xerox Corporation. All rights reserved.
  3.   Use and copying of this software and preparation of derivative works based
  4.   upon this software are permitted. Any distribution of this software or
  5.   derivative works must comply with all applicable United States export
  6.   control laws. This software is made available AS IS, and Xerox Corporation
  7.   makes no warranty about the software, its performance or its conformity to
  8.   any specification. Any person obtaining a copy of this software is requested
  9.   to send their name and post office or electronic mail address to:
  10.     PCR Coordinator
  11.     Xerox PARC
  12.     3333 Coyote Hill Rd.
  13.     Palo Alto, CA 94304
  14.   endcopyright */
  15.  
  16. /*
  17.  * CirioNubProcs2.c
  18.  *
  19.  * Demers, November 2, 1989 10:29:11 am PST
  20.  */
  21.  
  22.  
  23. #include "xr/CirioNubProtocol.h"
  24. #include "xr/CirioNubMarshall.h"
  25. #include "xr/CirioNubProcs.h"
  26. #include "xr/CirioNubEnvironment.h"
  27.  
  28. #include <sys/types.h>
  29. #include <sys/stat.h>
  30. #include <fcntl.h>
  31. #include <errno.h>
  32.  
  33.  
  34. CirioNubRetCode
  35. CirioNubServeOpenPath(argc, args)
  36.     int argc;
  37.     unsigned *args;
  38. {
  39.     int fd;
  40.     CirioNubRetCode ans;
  41.  
  42.     if( argc != 1 )
  43.     return(cnrc_badArgs);
  44.     fd = open(args[0], O_RDONLY, 0);
  45.     if( fd < 0 ) fd = (-errno);
  46.     if( (ans = CirioNubPutInt32(fd)) != cnrc_ok )
  47.     return ans;
  48.     return cnrc_ok;
  49. }
  50.  
  51.  
  52.  
  53. CirioNubRetCode
  54. CirioNubServeCloseFile(argc, args)
  55.     int argc;
  56.     unsigned *args;
  57. {
  58.     int closeAns;
  59.     CirioNubRetCode ans;
  60.  
  61.     if( argc != 1 )
  62.     return(cnrc_badArgs);
  63.     closeAns = close(args[0]);
  64.     if( closeAns < 0 ) closeAns = (-errno);
  65.     if( (ans = CirioNubPutInt32(closeAns)) != cnrc_ok )
  66.     return ans;
  67.     return cnrc_ok;
  68. }
  69.  
  70.  
  71.  
  72. CirioNubRetCode
  73. CirioNubServeLSeekFile(argc, args)
  74.     int argc;
  75.     unsigned *args;
  76. {
  77.     int seekAns;
  78.     CirioNubRetCode ans;
  79.  
  80.     if( argc != 3 )
  81.     return(cnrc_badArgs);
  82.     seekAns = lseek(args[0], args[1], args[2]);
  83.     if( seekAns < 0 ) seekAns = (-errno);
  84.     if( (ans = CirioNubPutInt32(seekAns)) != cnrc_ok )
  85.     return ans;
  86.     return cnrc_ok;
  87. }
  88.  
  89.  
  90.  
  91. CirioNubRetCode
  92. CirioNubServeReadFile(argc, args)
  93.     int argc;
  94.     unsigned *args;
  95. {
  96.     int len, readAns;
  97.     CirioNubRetCode ans;
  98. #   ifndef MAXREADFILELEN
  99. #       define MAXREADFILELEN 2048
  100. #   endif
  101.     char buf[MAXREADFILELEN];
  102.  
  103.     if( argc != 2 )
  104.     return(cnrc_badArgs);
  105.     if( (len = args[1]) > MAXREADFILELEN )
  106.         return(cnrc_badArgs);
  107.     readAns = read(args[0], buf, args[1]);
  108.     if( readAns >= 0 ) {
  109.         if( (ans = CirioNubPutInt32(readAns)) != cnrc_ok )
  110.         return ans;
  111.     if( (ans = CirioNubPutBlock8(buf, readAns)) != cnrc_ok )
  112.         return ans;
  113.     } else {
  114.         if( (ans = CirioNubPutInt32(-errno)) != cnrc_ok )
  115.         return ans;
  116.     if( (ans = CirioNubPutBlock8(buf, 0)) != cnrc_ok )
  117.         return ans;
  118.     }
  119.     return cnrc_ok;
  120. }
  121.  
  122.  
  123. CirioNubRetCode
  124. CirioNubServeStatPath(argc, args)
  125.     int argc;
  126.     unsigned *args;
  127. {
  128.     int statAns;
  129.     CirioNubRetCode ans;
  130.     struct stat statBuf;
  131.  
  132.     if( argc != 1 )
  133.     return(cnrc_badArgs);
  134.     statBuf.st_mtime = 0;
  135.     statBuf.st_size = 0;
  136.     statAns = stat(args[0], &statBuf);
  137.     if( statAns < 0 ) statAns = (-errno);
  138.     if( (ans = CirioNubPutInt32(statAns)) != cnrc_ok )
  139.     return ans;
  140.     if( (ans = CirioNubPutCard32(statBuf.st_mtime)) != cnrc_ok )
  141.     return ans;
  142.     if( (ans = CirioNubPutCard32(statBuf.st_size)) != cnrc_ok )
  143.     return ans;
  144.     return cnrc_ok;
  145. }
  146.  
  147.  
  148.  
  149.